<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<div class="box m">
	<div class="btitle path">
		<a title="<spring:message code="top.header.homepage" />" href="goHomePage.html"><spring:message code="top.header.homepage" /></a>&nbsp;»&nbsp; <a
			href="goProducts.html"><spring:message code="top.header.product" /></a>
	</div>
	<div class="bCt productLs">
		<c:forEach items="${productList}" var="p">
			<div class="it">
				<a title="<c:out value='${p.name}'/>" href="viewProduct.html?pId=${p.id}"> <span class="t"><c:out value='${p.name}' /></span> <c:if
						test="${not empty p.productImages}">
						<img style="max-width: 120px; max-height: 100px;" alt="${p.name}" src="<c:url value="loadImage.html?type=THUMB&fileId=${p.productImages[0]}"/>" border="0">
					</c:if>
				</a>
				<div class="pr">${p.getUnitPriceAsSale()}</div>
				<p>
					<c:out value='${p.highlight}' />
				</p>
				<div class="btn buy">
					<a title="<spring:message code="cart.buy" />" href="javascript:addToCart(${p.id},'${p.name }',${p.productImages},${p.unitPrice});"><spring:message code="cart.buy" /></a>
				</div>
			</div>
		</c:forEach>

		<c:if test="${empty productList }">
			<spring:message code="product.no.available" />
		</c:if>
		<div class="clear"></div>
		<c:if test="${not empty productList }">
			<c:if test="${productList[0].totalPage > 1}">
				<div style="text-align: center;" class="pages">
					<div style="display: inline-block;">
						<spring:message code="page.pagination.title" />
						<c:forEach begin="1" end="${productList[0].totalPage}" step="1" var="page">
							<c:if test="${page == param.page }">
								<span class="current">${page}</span>&nbsp;|
							</c:if>

							<c:if test="${!(page == param.page)}">
								<c:choose>
									<c:when test="${keyword!=null}">
										<span><a href="javascript:searchProductByKeyword(${page});" >${page}</a></span>&nbsp;|
									</c:when>
									<c:otherwise>
										<span><a href="searchProduct.html?page=${page}&productGroupId=${productGroupId}">${page}</a></span>&nbsp;|
								</c:otherwise>
								</c:choose>
							</c:if>
						</c:forEach>
					</div>
				</div>
			</c:if>
		</c:if>
	</div>
</div>
